@extends('admin.layouts.app')
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">车型管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="{{url('zadmin/car-models')}}">系统</a></li>
                                    
                                    <li class="active">修改车型</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                            <h2 class="m-t-0 header-title">修改车型</h2>
                            <hr/>
                             @if(session('rs'))
                              <div class="alert alert-{{session('rs')['status']}}">
                                {{ session('rs')['msg'] }}
                              </div>
                              @endif
                        			<div class="row">
			                        	<div class="col-md-6">
                                  <form class="form-horizontal" role="form" action="{{url('zadmin/car-models/'.$data->id)}}" method="post" enctype="multipart/form-data">{{ method_field('PUT') }}

                <div class="form-group">
                  <label class="col-md-2 control-label">品牌</label>
                  <div class="col-md-10">
                    <select  class="form-control select2" name="brand_id" required=""  id="brand_id">
                     
                      @foreach($brands as $b)
                      <option value="{{$b->id}}" {{$data->brand_id==$b->id?'selected':''}}>{{$b->name}}</option>
                      @endforeach
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-md-2 control-label">车系</label>
                  <div class="col-md-10">
                    <select  class="form-control select2" name="series_id" required="" id="series_id" >
                      @foreach($series as $s)
                      <option value="{{$s->id}}" {{$data->series_id==$s->id?'selected':''}}>{{$s->name}}</option>
                      @endforeach
                      
                    </select>
                  </div>
                </div>                              
                <div class="form-group">
                  <label class="col-md-2 control-label">车型名称</label>
                  <div class="col-md-10">
                    <input type="text" class="form-control" name="name" value="{{$data->name}}" required="">
                  </div>
                </div>    

                                              <div class="form-group text-center">
                                                  
                                                  <button type="submit" class="btn btn-info waves-effect waves-light">保存</button>
                                              </div>
                                              
                                              
                             {{csrf_field()}}
                                          </form>
                                </div>
			                        	
			                        </div>

                             
			                        
                        			
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            
    @section('modal')        
      
    @endsection        
       

           



    
        @section('js')

        <script type="text/javascript">
         

           $('#brand_id').on('change',function(){
          var _this    = $(this);
    var brand_id = _this.val();
    var url = "{{url('api/car-series')}}";
       
     $.get(url,{'brand_id':brand_id},function(rs){
            if(rs.status==true) {
                var service = $('#series_id');
                service.empty();
                var opt = '';
                $.each(rs.data,function(k,v){
                    opt += '<option value="'+v.id+'">'+v.name+'</option>'; 
                });
                 service.append(opt);
                
            }
        })
      });
        </script>
        @endsection
    
